import React from "react";
import {add, sub, asyncAdd} from '../../app/slices/countSlice';
import { useDispatch } from "react-redux";

export default function Button() {
  //获取 dispatch 函数
  let dispatch = useDispatch();
  return (
    <>
      <button onClick={() => {
        dispatch(add(1));
      }}>新增</button>
      <button onClick={() => {
        dispatch(sub(1))
      }}>减少</button>

      <button onClick={() => {
        dispatch(asyncAdd(10));
      }}>1 秒后增加 10</button>
    </>
  );
}
